import { _decorator, Component, Label, Node } from 'cc';
import { ModuleBase } from '../Card/ModuleBase';
import { ModuleMgr } from '../Card/ModuleMgr';
import { CardMgr } from '../Card/CardMgr';
const { ccclass, property } = _decorator;

@ccclass('Cardnum')
export class Cardnum extends ModuleBase {
    private cardnumL:Label=null;
    //最大牌数
    private cardmaxnum:number=0;
    //剩余牌数
    private cardnum:number=0;
    onInit(...rest: any[]): void {
        let cardMgr=ModuleMgr.instance.getModuel<CardMgr>("CardMgr");
        this.cardmaxnum=cardMgr._cardnum;
        this.cardnum=this.cardmaxnum;
        this.cardnumL=this.node.getChildByName("_CardnumLabel").getComponent(Label);
        this.cardnumL.string=this.cardnum.toString()+"/"+this.cardmaxnum.toString();
    }
    //剩余牌数修改
    cardNumModify(num:number){
        this.cardnum-=num;
        this.cardnumL.string=this.cardnum.toString()+"/"+this.cardmaxnum.toString();
    }
}


